<template>
    <div class="page">
        <!-- 导航栏 -->
        <div class="navBar">
            <customNavBar :leftTetx=leftTetx :titleTest=titleTest></customNavBar>
        </div>
        <!-- 页面内容 -->
        <div class="content">
            <van-list class="vanList" v-model:loading="loading" :finished="finished" finished-text="没有更多了">
                <van-cell class="cells" v-for="(v, c) in listDataCompleted" :key="c">
                    <!-- :class="v.reportType == '1' ? 'jbReport' : 'xbReport'" -->
                    <div class="card">
                        <img class="j" src="../../assets/img/listReport/jb.png" alt="" v-if="v.reportType == '1'">
                        <img class="j" src="../../assets/img/listReport/xb.png" alt="" v-else>
                        <div class='reportStstus'>{{ v.authFlag == 0 ? '未授权' : v.authFlag == 1 ? '已授权' : '授权已过期' }}</div>
                        <div class='cardT'>
                            <div class="labelsTop" style="width: 80%;">
                                <!-- <span>[客户{{v.readStatus == 0 ? '未读' : '已读' || '已读'}}]</span> {{v.monManName}}刘青的保单检视报告 -->
                                {{ v.monManName }}的保单检视报告
                                <img src="../../assets/img/listReport/wd.png" alt=""
                                    v-if="v.readStatus == '1' || v.readStatus == 'null'">
                                <img src="../../assets/img/listReport/yd.png" alt="" v-else>
                            </div>
                            <div class='reportSec'>
                                <div class='reportSecon'>
                                    <div class="labels">
                                        <span class='labelst'>演示期间</span>
                                        <span class="textContent">{{ v.reportParam1 || '0' }}</span>
                                    </div>
                                    <div class="labels1" v-if="v.authFlag == 0 || v.authFlag == 2">
                                        <span class='labelst'>请输入分享码</span>
                                        <div class="textContent">
                                            <input type="请输入分享码" v-model="v.authorizationCode">
                                            <!-- <img src="../../assets/img/listReport/qr.png" alt="" v-if="v.isShowButton"
                                                @click="sCode(v,c)">
                                            <img  src="../../assets/img/listReport/hqr.png" alt="" v-else="v.isShowButton"
                                               > -->
                                               <div v-log-button-name="'保单检视_报告列表_激活验证码'"  @click="sCode(v,c)" class='btnscode' v-if="v.isShowButton">
                                                确定</div>
                                               <div  v-log-button-name="'保单检视_报告列表_激活验证码'"   class='btnscodedis' v-else="v.isShowButton">
                                                确定</div>
                                        </div>
                                    </div>
                                    <div class="labels" v-else>
                                        <span class='labelst'>报告查看期间</span>
                                        <span class="textContent">{{ v.reportStartTime }}至{{ v.reportEndTime || '2023-10-10 至 2024-10' }}</span>
                                    </div>
                                </div>
                                <!-- <img src="../../assets/img/listReport/jt.png" alt="" @click="goDetails(v)"> -->
                            </div>
                            <div class='vanb1'>
                                <!-- <div @click="goDetails(v)" class='vanbDev'><img src="../../assets/img/listReport/ck.png"  alt="" >查看报告</div> -->
                                <!-- <div class="vanbDev" @click="unock(v.taskCode)"><img src="../../assets/img/listReport/ck.png" alt="">解锁详版</div> -->
                                <div @click="shareRpt(v)" class='vanbDev1'><img
                                        src="../../assets/img/listReport/fx1.png" alt="" v-log-button-name="'保单检视_报告列表_分享'">分享报告链接</div>
                                <div v-if="v.authFlag == 1" @click="goDetails(v)" class='vanbDev' v-log-button-name="'保单检视_报告列表_查看'"><img
                                    src="../../assets/img/listReport/ck.png" alt="">查看报告</div>
                                
                            </div>
                        </div>
                    </div>
                </van-cell>
            </van-list>
        </div>
    </div>
</template>

<script lang="ts" setup name="addCustomers">
import { useRouter, useRoute } from "vue-router"
import { Toast } from '/@/utils/Message';
import { onMounted } from "vue"
import { reactive, ref } from 'vue'
import customNavBar from "/src/components/NavBar/customNavBar.vue"
import { radioGroupProps } from 'vant';
import { json } from 'stream/consumers';
import { selectTaskReportList, nock, validateAuthorizationCode } from "/@/api/auth/index"

const router = useRouter()
const route = useRoute()
const leftTetx = ref<string>("")
const titleTest = ref<string>("报告列表")

const loading = ref<boolean>(false)
const finished = ref<boolean>(false)
// let taskId = ref<string>('')
sessionStorage.removeItem('showOverlay');
const columns = [
    { text: '10年', value: '0' },
    { text: '20年', value: '1' },
    { text: '30年', value: '2' },
    { text: '终身', value: '3' },
];
// 报告类型 reportType 1简版
// 演示期间 reportParam 
// isExpire 是否过期不能点详情
// isUnlock 是否解锁false展示 解锁祥版
const listDataCompleted = ref([])

const unock = (v: any) => {
    //  let   encrypttaskCode = JIAMIPublicData(v)
    nock({ taskCode: v }).then((res: any) => {
        Toast(res.msg)
        if (res.code == 200) {
            eportList()
        }
    })
}
// 输入验证码
const sCode = (v: any,c:any) => {
    if (!v.authorizationCode) {
        Toast('请输入分享码')
        return
    }
    validateAuthorizationCode({ taskCode: v.taskCode, reportType: v.reportType, authorizationCode: v.authorizationCode }).then((res: any) => {
        if (res.code == 200) {
            Toast('成功')
            eportList()
        } else if (res.code == 47004) {
            Toast(res.msg)
            // 置灰对应按钮
            // eportList()
            v.isShowButton = !v.isShowButton
            // listDataCompletedp[c] =  v
        }else {
            Toast(res.msg)
        }
    })
}
// 去报告详情
const goDetails = (v: any): void => {
    sessionStorage.setItem('showOverlay', 'true');
    router.push({
        name: "DetailedVersion",
        query: {
            taskCode: v.taskCode,
            reportType: v.reportType,
            // taskId: v.taskId,
            userType: '03',
            // readStatus:readStatus
        }
    })
}
const taskCode = route.query.taskCode

// 获取列表信息
const eportList = () => {
    selectTaskReportList({ taskCode }).then((res: any) => {
        if (res.code == 200) {
            listDataCompleted.value = res.data;


            columns.map((v) => {
                listDataCompleted.value.map((q) => {
                    if (v.value == q.reportParam) {
                        q.reportParam1 = v.text
                        loading.value = true
                        finished.value = true
                    }
                })
            })
        }
    })
}
// 跳转分享报告页
let shareRpt = (v: any) => {
    router.push({
        name: 'InviteCode',
        // isShow:"1" 用来去区别是不是分享二维码这里进入的二维码页面，控制显示
        query: {
            expirationTime: v.urlExpirationTime,
            longUrl: v.qrCodeUrl,
            shortUrl: v.shortLink,
            // shortUrl: 'http://172.20.14.114/policyReviewH5/letterAdvce?sl=EF3dj1oDWKr',
            isShow: "1",//控制二维码页面
            taskId: route.query.taskId,
            isTask: '1' //判断是否返回上一页
        }
    })
}
onMounted(() => {
    eportList()
})

</script>

<!-- less嵌套设置 -->
<style lang="less" scoped>
.verson {
    z-index: 1;
    font-size: 13px;
    color: #198AFA;
    position: absolute;
}

.page {
    background-color: #F5F7FA;
    height: 100vh;
    width: 100vw;
    overflow: hidden;

    .navBar {
        height: 58px;
        :deep(.van-nav-bar) {
            background-color: white;
        }

        :deep(.van-nav-bar__content) {
            background-color: white;
        }
    }

    .content {
        width: 100%;
        height: calc(100% - 58px);
        overflow: scroll;
        box-sizing: border-box;

        .vanList {
            margin-bottom: 20px;
            //background-color: #F5F7FA;


            :deep(.van-cell:after) {
                border: none;
            }

            .cells {
                background-color: #F5F7FA;

                .card {
                    // width: 355px;
                    width: 100%;
                    margin: 0 auto;
                    // display: flex;
                    overflow: hidden;
                    text-align: left;
                    border-radius: 10px;
                    background: #FFFFFF;
                    .cardT {
                        margin-left: 10px;
                    }

                    .reportStstus {
                        width: 80%;
                        font-size: 13px;
                        margin: 10px 0 0 10px;
                    }

                    .labelsTop {
                        display: flex;
                        font-size: 15.3px;
                        color: #222222;
                        font-weight: 600;
                        padding-top: 7px;
                        align-items: center;

                        span {
                            color: #198AFA;
                        }

                        img {
                            width: 55px;
                            height: 18px;
                            margin-left: 7px;
                        }
                    }

                    .reportSec {
                        // width: 324px;
                        width:95%;
                        height: 87px;
                        margin-top: 10px;
                        background: url(../../assets/img/listReport/centerBj.png);
                        background-size: 100% 100%;
                        background-repeat: no-repeat;

                        .reportSecon {
                            width: 100%;

                            .labels {
                                width: 100%;
                                height: 43px;
                                display: flex;
                                align-items: center;
                                justify-content: space-between;
                                font-size: 13px;
                                padding: 0 10px;

                                span {
                                    display: block;
                                }

                                .labelst {
                                    font-size: 13px;
                                    font-weight: 400;
                                    color: #868686;
                                }

                                .textContent {
                                    margin-left: 7px;
                                    color: #222222;
                                    font-weight: bold;
                                }
                            }

                            .labels1 {
                                width: 100%;
                                height: 43px;
                                display: flex;
                                align-items: center;
                                justify-content: space-between;
                                font-size: 13px;
                                padding: 0 10px;

                                .labelst {
                                    width: 40%;
                                    display: block;
                                    font-size: 12px;
                                    font-weight: 400;
                                    color: #198AFA;
                                }

                                .textContent {
                                    display: flex;
                                    margin-left: 7px;
                                    color: #222222;
                                    font-weight: bold;
                                    align-items: center;

                                    input {
                                        width: 70%;
                                        height: 25px;
                                        text-align: right;
                                        background: url(../../assets/img/listReport/inputBj.png);
                                        background-size: 100% 100%;
                                        background-repeat: no-repeat;
                                        padding-right: 8px;
                                    }

                                    img {
                                        width: 30px;
                                        height: 25px;
                                    }
                                    .btnscode{
                                        width: 70px;
                                        height: 30px;
                                        display: flex;
                                        margin-left: 7px;
                                        color: #FFFFFF;
                                        border-radius: 6px;
                                        align-items: center;
                                        justify-content: center;
                                        background: linear-gradient(#9acafbb5 0%, #7db9f5 48%, #6eb2f6 100%);
                                    }
                                    .btnscodedis{
                                        width: 70px;
                                        height: 30px;
                                        display: flex;
                                        margin-left: 7px;
                                        color: #FFFFFF;
                                        border-radius: 6px;
                                        align-items: center;
                                        justify-content: center;
                                        background: linear-gradient(#e3e0e0b5 0%, #c6c7c8 64%, #848585 100%);
                                    }
                                }
                            }
                        }

                        img {
                            width: 13px;
                            height: 13px;
                            margin-left: 7px;
                        }
                    }

                    .vanb {
                        display: flex;
                        cursor: pointer;
                        font-size: 10px;
                        margin-bottom: 17px;

                        div {
                            color: #198AFA;
                            border-radius: 3px;
                            border: 1px solid #198AFA;
                            padding: 0px 7px;
                            background: rgba(25, 138, 250, 0.05)
                        }

                        .vanbt {
                            width: 139px;
                            height: 28px;
                            display: flex;
                            color: #298BF0;
                            align-items: center;
                            background: #F4FAFF;
                            justify-content: center;

                            img {
                                top: -1px;
                                width: 17px;
                                height: 17px;
                                margin-right: 3px;
                                position: relative;
                            }
                        }

                        .vanbm {
                            width: 139px;
                            height: 28px;
                            display: flex;
                            color: #FFFFFF;
                            margin-left: 10px;
                            align-items: center;
                            justify-content: center;
                            background: linear-gradient(360deg, #44A1FD 0%, #2792FC 48%, #298BF0 100%);
                            box-shadow: 0px 2 4px 0px rgba(0, 101, 204, 0.1), 0px 1 2px 0px rgba(144, 206, 246, 0.5);

                            img {
                                top: -1px;
                                width: 17px;
                                height: 17px;
                                margin-right: 3px;
                                position: relative;
                            }
                        }
                    }

                    .vanb1 {
                        width: 93%;
                        display: flex;
                        font-size: 13px;
                        margin-top: 10px;
                        margin-bottom: 17px;
                        justify-content: space-between;

                        .vanbDev {
                            width: 113px;
                            height: 30px;
                            display: flex;
                            color: #198AFA;
                            border-radius: 7px;
                            align-items: center;
                            border-radius: 13px;
                            justify-content: center;
                            border: 1px solid #198AFA;
                        }

                        .vanbDev1 {
                            width: 113px;
                            height: 30px;
                            display: flex;
                            color: #FFFFFF;
                            border-radius: 7px;
                            border-radius: 13px;
                            align-items: center;
                            justify-content: center;
                            background: linear-gradient(#44A1FD 0%, #2792FC 48%, #298BF0 100%);
                        }

                        img {
                            width: 17px;
                            height: 17px;
                            margin-right: 3px;
                        }
                    }
                }
                .j {
                    right: 0;
                    width: 63px;
                    height: 30px;
                    position: absolute;
                }
                .xbReport {
                    // background: url(../../assets/img/listReport/bj.png);
                    // background-size: 100% 100%;
                    // background-repeat: no-repeat;
                }

                .jbReport {
                    // background: url(../../assets/img/listReport/bj1.png);
                    // background-size: 100% 100%;
                    // background-repeat: no-repeat;
                }
            }
        }
    }
}
</style>
